<?php
namespace Core\Debugger;

/**
 * Logger
 * @namespace Core\Debugger
 * @author Raphael DE FREITAS (RaphyTheGeek@gmail.com)
 * @version 1.0
 */
class Logger
{
	/**
	 * Contains the log entries
	 * @var array
	 * @see log
	 */
	protected static $_Entries = array();
	
	/**
	 * Initializes a new instance of the Logger class
	 */
	private function __construct(){
	}
	
	/**
	 * Add the LogEntry object specified into the entries of the logger
	 * @param LogEntry $log
	 */
	public static function log(LogEntry $log) {
		array_push(self::$_Entries, $log);
	}
	
	/**
	 * Display the entries
	 */
	public static function display() {
		echo '<ul style="list-style-type: none;padding-left: 0px;">';
		foreach(self::$_Entries as $entry) {
			$color = null;
			if($entry->getLevel() === AlertLevel::Warning){ $color = 'color:orange;font-weight:bold;'; }
			echo '<li style="margin-bottom:5px;'.$color.'"><span style="float: left;width:100px;"><b>'.$entry->getLevel().'</b></span> <em>'.$entry->getMessage().'</em></li>';
		}
		echo '</ul>';
	}
}
?>